package com.controller;

import com.page.GenericPage;
import com.result.Result;
import com.service.SettleService;
import com.vo.AgentAccountVO;
import com.vo.SettleVO;
import com.vo.SysUserVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Author: chihaojie
 * @Date: 2019/8/3 20:47
 * @Version 1.0
 * @Note
 */
@Api(value = "settleApi")
@CrossOrigin
@RestController
@RequestMapping("/settle")
public class SettleController {


    @Autowired
    private SettleService settleService;



    @ApiOperation(value = "结算列表", httpMethod = "GET", notes = "结算列表")
    @RequestMapping(value = "/queryUnSettledPage", method = RequestMethod.GET)
    public Result<GenericPage<SettleVO>> querySettlePage(
                                                   @RequestParam(value = "agent",required = false) Long agent,
                                                   @RequestParam(value = "settleWay",required = false) Integer settleWay,
                                                   @RequestParam(value = "pageNo",defaultValue = "1") Integer pageNo,
                                                   @RequestParam(value = "pageSize",defaultValue = "20") Integer pageSize) {
        return new Result<GenericPage<SettleVO>>().ok(settleService.queryUnSettledPage(agent,settleWay,pageNo,pageSize));
    }


    @ApiOperation(value = "平台查看代理商结算记录", httpMethod = "GET", notes = "平台查看代理商结算记录")
    @RequestMapping(value = "/querySettleHistoryPage", method = RequestMethod.GET)
    public Result<GenericPage<SettleVO>> querySettleHistoryPage(
            @RequestParam(value = "agent",required = false) Long agent,
            @RequestParam(value = "settleWay",required = false) Integer settleWay,
            @RequestParam(value = "settleStatus",required = false) Integer settleStatus,
            @RequestParam(value = "pageNo",defaultValue = "1") Integer pageNo,
            @RequestParam(value = "pageSize",defaultValue = "20") Integer pageSize) {
        return new Result<GenericPage<SettleVO>>().ok(settleService.querySettleHistoryPage(agent,settleWay,settleStatus,pageNo,pageSize));
    }



    @ApiOperation(value = "查看代理商自己的历史结算记录", httpMethod = "GET", notes = "查看代理商自己的历史结算记录")
    @RequestMapping(value = "/queryMineSettledHistoryPage", method = RequestMethod.GET)
    public Result<GenericPage<SettleVO>> queryMineSettledHistoryPage(
            @RequestParam(value = "pageNo",defaultValue = "1") Integer pageNo,
            @RequestParam(value = "pageSize",defaultValue = "20") Integer pageSize) {
        return new Result<GenericPage<SettleVO>>().ok(settleService.queryMineSettledHistoryPage(pageNo,pageSize));
    }



    /**
     * 获取代理商列表
     */
    @ApiOperation(value = "获取代理商列表", httpMethod = "GET", notes = "获取代理商列表")
    @RequestMapping(value = "/queryAgentList", method = RequestMethod.GET)
    public Result<List<AgentAccountVO>> queryAgentList() {
        return new Result<List<AgentAccountVO>>().ok(settleService.queryAgentList());
    }



    /**
     * 结算接口
     */
    @ApiOperation(value = "结算接口", httpMethod = "GET", notes = "结算接口")
    @RequestMapping(value = "/settle", method = RequestMethod.GET)
    public Result<Boolean> settle(@RequestParam("id") Long  id) {
        return new Result<Boolean>().ok(settleService.settle(id));
    }


    /**
     * 获取财务账户数据信息
     */
    @ApiOperation(value = "获取财务账户数据信息", httpMethod = "GET", notes = "获取财务账户数据信息")
    @RequestMapping(value = "/queryFinanceAccount", method = RequestMethod.GET)
    public Result<AgentAccountVO> queryFinanceAccount() {
        return new Result<AgentAccountVO>().ok(settleService.queryFinanceAccount());
    }


}
